Skip to content

fix(web,mobile): thread setting changes no longer end background work from the client - #40846

Open
juliusmarminge wants to merge 7 commits into
mainfrom
factory/pr-24446-a1795350698
Open

juliusmarminge wants to merge 7 commits into
mainfrom
factory/pr-24446-a1795350698

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

Changing a thread's worktree from the web branch picker, or retrying a mode change from a mobile queued send, could end or permanently block a session that still had background agents or shells running. The server already refuses those changes while background work runs; this removes the two client paths that defeated it.

  • BranchToolbarBranchSelector no longer stops the thread session before changing its worktree. The server detaches the session itself, and refuses while background work runs.
  • Mobile settingsCommandId gives each runtime-mode and interaction-mode attempt its own command ID, because the server keeps a refusal under its ID and a retry under the same ID could never succeed. The queued /compact keeps its stable ID so a resend is still deduplicated.

Supersedes #24446. The change is @juliusmarminge's; their commits are kept.

Reproduction on main

On mobile, open a Claude thread in Full access and ask it to launch a native background Agent that continues after the parent turn completes. While that Agent is running, select Auto-accept edits and send a message, causing the outbox's runtime-mode synchronization to be refused. Let the Agent finish and allow delivery to retry, including reopening the thread or app: main reuses the rejected settings-command ID, whereas this change supplies a fresh ID so synchronization and delivery can proceed. These are code-derived steps, not an executed reproduction.

Evidence

Being captured: before and after in the real app. This section is filled in before the pull request can merge.

Tests

  • vp test run src/state/threadOutboxDelivery.permissions.test.ts (apps/mobile): 24 passed; the new case fails with the old fixed ID (1 failed, 23 passed)
  • vp run check:changed: format, lint, knip, typecheck (3 packages), tests (2 files) and React compiler all pass

Not in this change

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

juliusmarminge and others added 7 commits October 24, 2026 12:54
…ode, instance and worktree changes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and shells

Changing runtime mode, provider instance, or worktree detached the provider
session even while its process ran the thread's background agents and shells,
so that work died silently and the UI kept showing it as running (#16000).

The orchestrator now asks the live adapter whether a session the change would
detach still has this thread's background work, and refuses the change with a
retryable message instead. Archive, settle, and Stop still end the work.

The web branch picker no longer stops the session itself before a worktree
change; the server already detaches on that path, and the eager stop bypassed
the guard. Mobile outbox settings sync now uses a command id per retry
attempt, so a refused change can apply once the work finishes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd work on account changes

Exclusive sessions now ask the whole session for background work, since
Claude's thread probe sees shells but not native background Agents. A send
or queued send that would continue the native thread on another account
refuses while that work runs, like the settings changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ueue

A queued send refused because background work was still running was
classed as an unknown provider failure, so the next queued message held
the whole queue and nothing released it. The refusal is now a validation
failure: only that send fails and the queue keeps going.

Mobile settings command ids are now random per attempt, so a remount no
longer replays ids the server already refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main now guards every settings path that detaches a provider session
(#35029), so the branch's Orchestrator changes and their tests give way
to main's. What main lacks stays: the web branch picker no longer stops
the session before the server can refuse a worktree change, and mobile
mode changes get a fresh command id per attempt (the queued /compact
keeps its stable id so a resend is still deduplicated).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Mobile outbox settings commands now receive fresh IDs, while compact commands retain IDs derived from queued messages. The web branch selector no longer stops a thread session when its worktree path changes.

Changes: Mobile outbox delivery

Layer / File(s) Summary
Command IDs and retry behavior
apps/mobile/src/state/threadOutboxDelivery.ts, apps/mobile/src/state/threadOutboxDelivery.permissions.test.ts
Settings command IDs receive fresh random suffixes. Compact command IDs use the queued message ID with a :compact suffix. A test verifies that a later delivery after a refused update uses a different runtime-mode command ID and removes the queued message.

Web branch selector

Layer / File(s) Summary
Worktree change handling
apps/web/src/components/BranchToolbarBranchSelector.tsx
The selector no longer stops the thread session when the worktree path changes. The metadata update flow remains.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: maria-rcks

Merge Risk: Minimal · up to 0c4a2

This change lets a refused mobile settings update be retried after background work finishes, and it removes a web branch-picker session stop that bypassed the server's guard. No actionable merge risk was identified in the supplied context.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: thread setting changes no longer end background work from the client. It covers both the web branch picker and the mobile settings command IDs, both in the changeset. …
Description check Passed The description follows the template sections: Problem, Change, Scope, Verification, and an agent attribution line. It explains the bug, the two client paths, and the fix. It links the superseded PR #…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: thread setting changes no longer end background work from the client. It covers both the web branch picker and the mobile settings command IDs, both in the changeset. It follows the conventional commit form. The wording is specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description follows the template sections: Problem, Change, Scope, Verification, and an agent attribution line. It explains the bug, the two client paths, and the fix. It links the superseded PR #24446 and notes that the branch's server changes were dropped. Verification lists focused tests and a repo check, and the new test is described with its failing result. The Evidence section is still pending, and the template's Problem and Scope sections are not labeled as in the template. The author states that the Evidence section must be filled before merge, and the UI change for the branch picker has no screenshot. These gaps are not critical to the fix but should be addressed before merge.

Resolution

Fill in the Evidence section with the before and after results in the real app, or confirm the change needs no UI evidence. Add an explicit Problem and Scope heading wording that matches the template, and link the issue or maintainer request that supports the bug fix.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 66ca7cd and 0c4a26e.

Files selected for processing: 3

  • apps/mobile/src/state/threadOutboxDelivery.permissions.test.ts
  • apps/mobile/src/state/threadOutboxDelivery.ts
  • apps/web/src/components/BranchToolbarBranchSelector.tsx
Files with no reviewable changes: 1

  • apps/web/src/components/BranchToolbarBranchSelector.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@juliusmarminge

Copy link
Copy Markdown
Member Author

The automated pipeline stopped on this pull request and will not merge it:

the fix is written and reviewed, but proving it needs something no worker has:

  • Permanent blocker: the supplied reproduction requires a usable Claude session with native background Agent support; the VM brief explicitly lists first-party Claude OAuth as unavailable. Although the installed CLI reported an OAuth login, no provider turn was attempted under the instruction not to work around this restriction.
  • Mobile settings refusal, retry after background completion, and persistence across reopening remain unverified on both commits.
  • Background-work preservation and removal of the web branch picker's eager Stop remain unverified in the real app.

It stays open for a person to finish or close.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant